// 是否持有指定的权限
import {usePmAppStore} from "@/stores";
import {storeToRefs} from "pinia";

const { userInfo } = storeToRefs(usePmAppStore());
export function hasPerm(permList: string[]): boolean {
  if (permList && permList.length > 0) {
    const all_permission = "*:*:*"; // 全部权限
    const permissions = userInfo.value.permissions // 用户拥有的权限标识的数组
    // 判断是否有权限
    return permissions.some((permission: string) => {
      return all_permission === permission || permList.indexOf(permission) !== -1
    })
  }
  return false
}
